/**
 * 
 */
package com.yidu.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.action.vo.StatisticsVo;
import com.yidu.domain.ListenBackstageUser;
import com.yidu.service.ListenBranchSellDetailService;
import com.yidu.service.ListenBranchWholesaleDateilService;
import com.yidu.service.ListenSellDetailService;

/**
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/statisticalChart")
public class StatisticalChartController {
	@Resource
	ListenSellDetailService listenSellDetailService;
	
	@Resource
	ListenBranchWholesaleDateilService listenBranchWholesaleDateilService;
	
	@Resource
	ListenBranchSellDetailService listenBranchSellDetailService;
	
	
	@RequestMapping("selectStatistics")
	@ResponseBody
	public List<StatisticsVo> selectStatistics(){
		 return listenSellDetailService.selectStatistics();
	}
	
	
	@RequestMapping("findCompanyId")
	@ResponseBody
	public String findCompanyId(HttpSession session){
		ListenBackstageUser users = (ListenBackstageUser) session.getAttribute("user");
		 return users.getSite();
	}
	
	
	@RequestMapping("selectYearStatistics")
	@ResponseBody
	public  List<StatisticsVo> selectYearStatistics(String year){
		 return listenSellDetailService.selectYearStatistics(year);
	}
	
	
	@RequestMapping("selectMonthsPriceStatistics")
	@ResponseBody
	public  List<StatisticsVo> selectMonthsPriceStatistics(String year){
		 return listenSellDetailService.selectMonthsPriceStatistics(year);
	}
	
	
	@RequestMapping("selectSumPriceStatistics")
	@ResponseBody
	public  List<StatisticsVo> selectSumPriceStatistics(String year){
		 return listenSellDetailService.selectSumPriceStatistics(year);
	}
	
	
	@RequestMapping("wholesaleStatistics")
	@ResponseBody
	public List<StatisticsVo> wholesaleStatistics(HttpSession session){
		ListenBackstageUser users = (ListenBackstageUser) session.getAttribute("user");
		Map<String, Object> map=new HashMap<>();
		map.put("companyId", users.getSite());
		map.put("start", 0);
		map.put("end", 8);
		
		 return listenBranchWholesaleDateilService.wholesaleStatistics(map);
	}
	
	@RequestMapping("retailStatistics")
	@ResponseBody
	public List<StatisticsVo> retailStatistics(HttpSession session){
		ListenBackstageUser users = (ListenBackstageUser) session.getAttribute("user");
		Map<String, Object> map=new HashMap<>();
		map.put("companyId", users.getSite());
		map.put("start", 0);
		map.put("end", 8);
		
		 return listenBranchSellDetailService.retailStatistics(map);
	}
	
	
	@RequestMapping("selectMonthsNumberPriceStatistics")
	@ResponseBody
	public  List<StatisticsVo> selectMonthsNumberPriceStatistics(HttpSession seesion,String year,String attribute){
		 return listenBranchWholesaleDateilService.selectMonthsNumberPriceStatistics(seesion,year,attribute);
	}
}
